/**
 * Created by Simon on 2017/4/17.
 */

$(function () {
  var vm = new Vue({
    el: "#banner-container",
    data: {
      isFormShow: false,
      editingItem: {
        id: '',
        name: '',
        imageUrl: '',
        status: '',
        updateTime: '',
        sortNumber: ''
      }
    },
    methods: {
      onAddClick: function () {
        this.isFormShow = true;
      },
      onEditClick: function (id) {
        $.get(`/manage/king-land/index/getBannerById?id=${id}`, (res) => {
          this.isFormShow = true;
          this.editingItem = res.banner;
        });
      },
      onDeleteClick: function (id) {
        $.get(`/manage/king-land/index/deleteBannerById?id=${id}`, res => {
          window.location.reload();
        });
      },
      onSubmitClick: function () {
        var form = this.$refs['banner-form'];
        form.submit();
      },
      onFileChange: function () {
        console.log('onFileChange');
      }
    },
    computed: {
      isSubmitEnabled: function () {
        return !!this.name;
      }
    }
  });
});